#
# This file is a part of the open-eBackup project.
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at
# http://mozilla.org/MPL/2.0/.
#
# Copyright (c) [2024] Huawei Technologies Co.,Ltd.
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
#

from enum import Enum


class ADDSCode(Enum):
    """
    返回给框架的code
    """
    SUCCESS = 0
    FAILED = 200
    RESOURCE_IS_NOT_EXIST = 0x64034212
    AD_SERVICE_NOT_INSTALLED = 0x5E025E72
    BACKUP_SERVER_NOT_INSTALLED = 0x5E025E73


class SubJobType(int, Enum):
    PRE_SUB_JOB = 0
    GENERATE_SUB_JOB = 1
    BUSINESS_SUB_JOB = 2
    POST_SUB_JOB = 3


class LogLevel(int, Enum):
    INFO = 1
    WARN = 2
    ERROR = 3
    SERIOUS = 4


class BackupType(str, Enum):
    # 备份类型
    FULL_BACKUP = "1"


class ADDSLabel:
    # 开始执行备份子任务（{0}）。
    START_BACKUP_LABEL = "plugin_start_backup_copy_subjob_label"
    # 正在备份Active Directory，已完成：{0}%。
    ADDS_BACKUP_RUNNING_LABEL = "adds_backup_running_label"
    # 正在恢复Active Directory，已完成：{0}%。
    ADDS_RESTORE_RUNNING_LABEL = "adds_restore_running_label"
    # 子任务（{0}）执行成功。
    PLUGIN_BACKUP_SUBJOB_SUCCESS_LABEL = "plugin_task_subjob_success_label"
    # 子任务（{0}）备份失败。
    EXECUTE_BACKUP_FAILED_LABEL = "plugin_backup_subjob_fail_label"
    # Active Directory备份子任务由于系统原因导致执行失败，系统错误码：{0}，错误描述：{1}。
    EXECUTE_BACKUP_SYSTEM_FAILED_LABEL = "adds_backup_subjob_failed_with_system_error_label"
    # Active Directory恢复子任务由于系统原因导致执行失败，系统错误码：{0}，错误描述：{1}。
    EXECUTE_RESTORE_SYSTEM_FAILED_LABEL = "adds_restore_subjob_failed_with_system_error_label"
    # 开始执行恢复子任务（{0}）。
    START_RESTORE_LABEL = "plugin_start_restore_copy_subjob_label"
    # "子任务（{0}）执行成功。"
    PLUGIN_RESTORE_SUBJOB_SUCCESS_LABEL = "plugin_task_subjob_success_label"
    # 子任务（{0}）恢复失败。
    EXECUTE_RESTORE_FAILED_LABEL = "plugin_restore_subjob_fail_label"
    # 恢复任务执行失败。对象（{distinguishedname}）已存在
    RESTORE_OBJECT_EXISTED = "restore_object_existed_label"
    # 计算机以目录服务恢复模式（DSRM）启动时才能恢复AD域
    ADDS_COMPUTER_NOT_IN_DSRM = "adds_computer_not_in_dsrm_label"
    # 计算机以正常模式启动时才能备份系统状态
    ADDS_BACKUP_COMPUTER_NOT_IN_NORMAL_MODE = "adds_computer_not_in_normal_mode_label"
    # 计算机以正常模式启动时才能进行对象级恢复
    ADDS_RESTORE_COMPUTER_NOT_IN_NORMAL_MODE = "adds_backup_computer_not_in_normal_mode_label"
    # 代理主机当前已有系统备份任务正在执行，请等待备份任务结束后再次启动任务
    ADDS_COMPUTER_OTHER_TASK_RUNNING = "adds_restore_computer_other_task_running_label"
    # 前置任务检查失败
    ADDS_PREREQUISITE_CHECK_FAILED = "virtual_plugin_restore_job_check_before_recover_failed_label"
    # Active Directory扫描进行中，已扫描{0}个文件。
    ADDS_SYSTEM_TASK_SCAN = "adds_system_task_scan_label"
    # Active Directory扫描完成。
    ADDS_SYSTEM_TASK_SCAN_COMPLETED = "adds_system_task_scan_completed_label"
    # DFSR服务状态异常
    ADDS_DFSR_SERVICE_ABNORMAL = "adds_dfsr_service_abnornal_label"
    # SYSVOL组件缺失
    ADDS_SYSVOL_COMPONENT_MISSING = "adds_sysvol_component_missing_label"


class ADDSParamConstant:
    # AD域默认备份目录
    ADDS_DIR = "WindowsImageBackup"


class TaskStatus(str, Enum):
    # 备份类型
    RUNNING = "Running"
    COMPLETED = "Completed"
    FAILED = "Failed"
